#!/usr/bin.python
# code : UTF-8

import os
import sys
import re
import logging as log
from Mysql import mysql_installer as mysql
from rabbitMq import rabbitmq_installer as rabbit
from iop_web import iopWeb as iop
from swifts import swift
from testUnit import tester
from report import recorder
from xtrabackup import xtrabackup 

def main(ips_worker,proxy,dev,ssl,commonPass,encryptedPass):
    E = recorder()
    M = mysql()
    R = rabbit()
    I = iop()
    S = swift()
    B = xtrabackup()
    if E.test("mysql-install"):
        M.mount(ips_worker,dev)
        M.install_mysql(ips_worker)
        E.record("mysql-install")
    if E.test("mysql-config"):
        M.operator(ips_worker,commonPass)
        E.record("mysql-config")
    if E.test("rabbitmq"):
        R.mount(ips_worker,dev)
        R.operator(ips_worker,commonPass)
        E.record("rabbitmq")
    if E.test("iop-web"):
        I.config(ips_worker,proxy,ssl,commonPass,encryptedPass)
        E.record("iop-web")
    if E.test("swift-install"):
	S.install(ips_worker)
        E.record("swift-install")
    if E.test("swift-config"):
        S.config(ips_worker,proxy,ssl,commonPass)
        E.record("swift-config")
    if E.test("mysql-backup"):
        B.install(ips_worker)
        B.backup(ips_worker,commonPass)
        E.record("mysql-backup")
    return

if __name__ == "__main__":
    T = tester()
    if not T.test():
        raise Exception("less arguments or illegal arguments.")
    ips_worker = T.get_ips_worker()
    main(ips_worker,"10.110.17.136")
